package com.zhonglz.commons.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.zhonglz.commons.interceptor.SysLogInterceptor;
import com.zhonglz.commons.interceptor.SystemInterceptor;

/***
 *  过滤器配置
 * @author zhonglz
 * @Date 2019年11月11日
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {

	@Bean
	public SysLogInterceptor sysLogInterceptor() {
		return new SysLogInterceptor();
	}
	
	@Bean
	public SystemInterceptor systemInterceptor() {
		return new SystemInterceptor();
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		super.addInterceptors(registry);
		
		registry.addInterceptor(sysLogInterceptor())
		//添加规则
		.addPathPatterns("/**")
		//放行
		.excludePathPatterns("/")
		
		.excludePathPatterns("/error/**");
		
		
		//系统会话拦截器
		registry.addInterceptor(systemInterceptor())
		//添加规则
		.addPathPatterns("/sys/**")
		//放行
		.excludePathPatterns("/error/**")//所有错误请求
		.excludePathPatterns("/sys/user/login") // 登陆
		.excludePathPatterns("/sys/user/getVerifyCode")// 获取登陆验证码
	
		.excludePathPatterns("/sys/file/uploadFile")//文件上传
		.excludePathPatterns("/sys/file/downloadFileByUUid")//文件查看 img
		.excludePathPatterns("/sys/file/downloadPdfByUUid")//文件查看pdf
		
		.excludePathPatterns("/sys/file/uploadFileToBase")//文件上传 base
		
		
		;
	}
	
	
}

